import allure
from appium.webdriver.common.appiumby import AppiumBy

from base.xueqiu_app import XueQiu
from page.free_page import FreePage
from page.search_page import SearchPage


class Main(XueQiu):
    # def __init__(self, driver: WebDriver):
    #     self.driver = driver

    _search = AppiumBy.ID, 'com.xueqiu.android:id/home_search'
    _zi = AppiumBy.XPATH, "//*[@text='自选' and @resource-id='com.xueqiu.android:id/tab_name']"

    @allure.step('主页')
    def search(self):
        # 主页
        self.find_ele_click(self._search)
        self.screen()
        return SearchPage(self.driver)

    @allure.step('自选页')
    def zi_xuan(self):
        # 点击自选
        self.find_ele_click(self._zi)
        self.screen()
        return FreePage(self.driver)
